<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="updateWarehouse" binding="#{warehouseManagerBean.loadUpdateWarehouse}">
                    <p:panel id="addZonePanel" header="Add a Zone">
                        <p:messages />

                        <table width="100%" border="0">
                            <tr>
                                <td width="170px">Status</td>
                                <td>
                                    <h:selectOneMenu id="selectOneWarehouseZone" value="#{warehouseManagerBean.warehouseZone.id}"
                                                     title="Warehouse zones.">
                                        <f:selectItem itemLabel="- Select Warehouse Zone -" itemValue="" />
                                        <f:selectItems value="#{warehouseManagerBean.warehouseZones2}" var="warehouseZone" 
                                                       itemLabel="#{warehouseZone.zoneName}" itemValue="#{warehouseZone.id}" />
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <p:commandButton id="btnAddZone" value="Add Zone"
                                                     ajax="true" title="Add a zone to this warehouse."
                                                     update="addZonePanel"
                                                     actionListener="#{warehouseManagerBean.addZone}"/>
                                    <p:commandButton id="btnBackFromUpdateWarehouse" value="Back"
                                                     immediate="true" ajax="true"
                                                     title="Go back to the previous page."
                                                     actionListener="#{warehouseManagerBean.back}"/>
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:panel id="zonesPanel" header="Zones">
                        <p:messages />

                        <table border="0" width="100%">
                            <tr>
                                <td>
                                    <p:dataTable id="warehouseZones" var="warehouseZone" value="#{warehouseManagerBean.warehouseZones}" selectionMode="single" 
                                                 selection="#{warehouseManagerBean.selectedWarehouseZone}" update="zonesPanel">
                                        <p:column filterBy="#{warehouseZone.zoneName}" headerText="Zone Name" filterMatchMode="contains">  
                                            <h:outputText value="#{warehouseZone.zoneName}" />  
                                        </p:column> 
                                        <p:column filterBy="#{warehouseZone.type}" headerText="Zone Type" filterMatchMode="contains">  
                                            <h:outputText value="#{warehouseZone.type}">
                                            </h:outputText>
                                        </p:column> 
                                        <p:column filterBy="#{warehouseZone.quantityLimit}" headerText="Quantity Limit" filterMatchMode="contains">  
                                            <h:outputText value="#{warehouseZone.quantityLimit}" />  
                                        </p:column>
                                        <p:column filterBy="#{warehouseZone.currentQuantity}" headerText="Current Quantity" filterMatchMode="contains">  
                                            <h:outputText value="#{warehouseZone.currentQuantity}" />  
                                        </p:column> 
                                    </p:dataTable>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <p:commandButton id="btnDeleteZone" value="Delete Zone"
                                                     ajax="true" title="Delete the selected zone for this warehouse."
                                                     update="zonesPanel"
                                                     actionListener="#{warehouseManagerBean.deleteZoneFromWarehouse}"/>
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
